//package com.woniu.utils;
//
//import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
//import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationOutput;
//import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
//import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
//import com.alibaba.dashscope.common.MultiModalMessage;
//import com.alibaba.dashscope.common.Role;
//import com.alibaba.dashscope.exception.ApiException;
//import com.alibaba.dashscope.exception.NoApiKeyException;
//import com.alibaba.dashscope.exception.UploadFileException;
//import com.alibaba.dashscope.utils.JsonUtils;
//
//import java.util.Arrays;
//import java.util.Collections;
//import java.util.Map;
//
//public class ALiYunUtils {
//    public static String simpleMultiModalConversationCall(String audioUrl)
//            throws ApiException, NoApiKeyException, UploadFileException {
//        MultiModalConversation conv = new MultiModalConversation();
//        MultiModalMessage userMessage = MultiModalMessage.builder()
//                .role(Role.USER.getValue())
//                .content(Arrays.asList(
//                        Collections.singletonMap("audio", audioUrl),
//                        Collections.singletonMap("text", "将音频的内容完整提取出来")))
//                .build();
//        MultiModalConversationParam param = MultiModalConversationParam.builder()
//                .model("qwen-audio-turbo-latest")
//                .message(userMessage)
//                .build();
//        MultiModalConversationResult result = conv.call(param);
//        // 只获取 AI 的回答内容
////        String answer = result.getOutput().getChoices();
////        System.out.println(JsonUtils.toJson(result));
//        return extractTextFromResult(result);
//    }
//    private static String extractTextFromResult(MultiModalConversationResult result) {
//        if (result != null && result.getOutput() != null && !result.getOutput().getChoices().isEmpty()) {
//            MultiModalConversationOutput.Choice choice = result.getOutput().getChoices().get(0);
//            if (choice.getMessage() != null && !choice.getMessage().getContent().isEmpty()) {
//                Object content = choice.getMessage().getContent().get(0);
//                if (content instanceof Map) {
//                    Map<String, String> contentMap = (Map<String, String>) content;
//                    return contentMap.get("text");  // ✅ 只返回 text 的值
//                }
//            }
//        }
//        return null; // 如果没有找到 text 内容则返回 null 或者抛出异常
//    }
//}
